GBML manual / Collision

tile_blocks_projectile

The projectile question: true only if the tile at (x, y) is TILE_SOLID - TILE_LOW_COVER lets a projectile pass (see tile_class). What a project’s own generated call should use for an object declared is_projectile, instead of tile_solid. The choice is the object’s own declared fact, never inferred by either function itself.

Syntax

tile_blocks_projectile(x, y) -> bool

Arguments

NameType
xreal
yreal

Returns

bool

Description

The projectile question: true only if the tile at (x, y) is TILE_SOLID. TILE_LOW_COVER lets a projectile pass over - see tile_class.

x and y are a place in the room, counted from the room's top-left corner. That is also where the tile grid starts, so the very first tile covers x from 0 to 7 and y from 0 to 7 (tiles are 8 by 8 pixels).

This is what a project's own code should call for an object declared is_projectile (the object panel's own property, not a GBML variable) instead of tile_solid - which of the two questions to ask is the object's own declared fact, never something either function works out on its own. An ordinary, non-projectile object (a walker, an enemy, the player) still wants tile_solid.

On a slope the answer is for the one pixel under the point, so a bullet stops on the line of a ramp and flies over its empty corner.

Like tile_solid, this looks at one point, and that is on purpose: a bullet really is a point. There is no "whole box" version of the projectile question. For a mover with size, see tile_free, which checks a whole box against the body question.

Example

if (tile_blocks_projectile(x, y)) {
    instance_destroy(self);
}

Stops a projectile's own flight the instant it reaches a TILE_SOLID tile - a TILE_LOW_COVER tile in the same spot would answer tile_solid (true, since it blocks a body) but lets this same projectile pass straight over it.

On the GBA

Same as tile_solid: a point outside the room does not block a projectile, because the edge of a room is not a wall. A room with no tile layer has nothing to block, so there it reads false.

See also: tile_solidtile_classtile_flagstile_freeSlopes